#include "add_data.h"
#include "ui_add_data.h"
add_data::add_data(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::add_data)
{
    ui->setupUi(this);
}

add_data::~add_data()
{
    delete ui;
}

void add_data::on_confirm_clicked()
{
    // 创建一个指向 QList 的指针
    QString s;
    s+=ui->a_name->text();
    s+=",";
    s+=ui->a_score->text();
    s+=",";
    s+=ui->a_num->text();
    s+=",";
    s+=ui->a_prenum->text();

    QString workingDirectory = QDir::current().path();
    workingDirectory=workingDirectory+"/data.txt";
    QFile file(workingDirectory); //路径选择
    file.open(QIODevice::WriteOnly | QIODevice::Append);
    QTextStream stream(&file);
    stream << s;
    stream << "\n";  // 换行
    file.close();
    this->close();
    emit newDataCome();
}


void add_data::on_cnacel_clicked()
{
    add_data::~add_data();
}

